package com.xbongbong.saas.enums;

import com.xbongbong.paas.constant.TimeConstant;
import lombok.Getter;

/**
 * @author youli.chen
 * @version v1.0
 * @description: 工作报告：截止时间枚举
 * @date 2019/3/12 10:09
 * @since v1.0
 */
@Getter
public enum DeadlineTimeEnum {

    // 截止时间 九点
    DEADLINE_TIME_NINE(TimeConstant.SECONDS_PER_HOUR * 9, "09:00"),
    // 截止时间 十点
    DEADLINE_TIME_TEN(TimeConstant.SECONDS_PER_HOUR * 10, "10:00"),
    // 截止时间 十二点
    DEADLINE_TIME_TWELVE(TimeConstant.SECONDS_PER_HOUR * 12, "12:00"),
    // 截止时间 十八点
    DEADLINE_TIME_EIGHTEEN(TimeConstant.SECONDS_PER_HOUR * 18, "18:00"),
    // 截止时间 23:59
    DEADLINE_TIME_TWENTY_FOUR(TimeConstant.SECONDS_PER_DAY, "23:59");

    private int timestamp;
    private String name;

    DeadlineTimeEnum(int timestamp, String name) {
        this.timestamp = timestamp;
        this.name = name;
    }

    public static DeadlineTimeEnum getDeadlineTimeByName(String name) {
        if (name == null) {
            return null;
        }
        for (DeadlineTimeEnum cacheCode : values()) {
            if (name.equals(cacheCode.getName())) {
                return cacheCode;
            }
        }
        return null;
    }
}
